package com.spring.controller;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.spring.model.User;
import com.spring.service.IUserService;
@Controller
@RequestMapping("/user")
public class UserController {
	private IUserService userService;

	public IUserService getUserService() {
		return userService;
	}
	@Inject
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}
	
	public void addUser(User user) {
		userService.addUser(user);
	}

	public void delUser(int id) {
		userService.delUser(id);
	}

	public void updateUser(int id) {
		userService.updateUser(id);
	}
	@RequestMapping(value={"/{id}/load"},method=RequestMethod.GET)
	public String loadUser(@PathVariable int id,Model model){
		userService.loadUser(id);
		model.addAttribute("id", id);
		return "user";
	}
}
